import { TimerService } from '../schedule/TimerService';
import { AuthGuard } from 'src/auard/AuthAuard';
import { APP_GUARD } from '@nestjs/core';
import { RolesGuard } from 'src/auard/RoleAuard';
import { RedisServer } from 'src/config/Redis';
import { APP_INTERCEPTOR } from '@nestjs/core';
import { LoggingInterceptor } from './LoggingInterceptor';
import { AudioConsumer, AudioEventsListener } from './../bullmqconsumer/AudioConsumer';
import { ThrottlerGuard } from '@nestjs/throttler';

const provideFun = (): Array<any> => {
    const providerList = [];
    // 注册登陆认证注解：@AuthGuard()
    providerList.push({
        provide: APP_GUARD,
        useClass: AuthGuard,
    });
    // 注册权限认证注解：@RolesGuard()
    providerList.push({
        provide: APP_GUARD,
        useClass: RolesGuard,
    });
    // 请求日志拦截器
    providerList.push({
        provide: APP_INTERCEPTOR,
        useClass: LoggingInterceptor,
    });
    // redis
    providerList.push(RedisServer);
    // 定时器
    providerList.push(TimerService)
    // 消费者
    providerList.push(AudioConsumer)
    // 监听器
    providerList.push(AudioEventsListener)
    // 注册限流注解：@ThrottlerGuard
    providerList.push({
        provide: APP_GUARD,
        useClass: ThrottlerGuard
    });

    return providerList;
};

export default provideFun()
